
package framework.factory.customer;


import framework.customer.CompanyCustomer;
import framework.customer.ICustomer;
import framework.customer.PersonalCustomer;

import java.util.HashMap;
import java.util.Map;


public class CustomerFactory implements ICustomerFactory{
    private final String COMPANY_CUSTOMER = "C";
//    private static final Map<String, CustomerFactory> custPrototype = new HashMap<String, CustomerFactory>();
//
//    static {
//        custPrototype.put("P", new PersonalCustomerFactory());
//        custPrototype.put("CC", new PersonalCustomerFactory());
//        custPrototype.put("C", new CompanyCustomerFactory());
//    }

//    public abstract ICustomer getCustomer(Map<String, String> val);

     public ICustomer createCustomer(Map<String, String> vals) {
        if (COMPANY_CUSTOMER.equals(vals.get("p/c")))
            return new CompanyCustomer(vals);
         return new PersonalCustomer(vals);
    }


//    public static ICustomer createCustomer(Map<String, String> vals) {
//        if (!custPrototype.containsKey(vals.get("p/c")))
//            return null;
//        return custPrototype.get(vals.get("p/c")).getCustomer(vals);
//    }
//
//    public static void registerNewCustomerFactory(String key, CustomerFactory factory) {
//        custPrototype.put(key, factory);
//    }
}

